Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

services and servlets #1

Merged
merged 1 commit into from
Sep 24, 2023

Conversation

abhishekanandttn
Copy link
Owner

AEM Services with multiple implementations.

@abhishekanandttn
Copy link
Owner Author

This PR involves the creation of a servlet in an AEM (Adobe Experience Manager) application that fetches image URLs from external services and renders them directly in the browser. Below are the key components and functionalities implemented:

  1. SearchImageServlet (SearchImageServlet.java):
  • A Sling Servlet that accepts user input to determine the type of image (e.g., "dog" or "fox").
  • Uses OSGi annotations for service binding and unbinding.
  • Fetches image URLs from external services based on the user's selected type.
  • Renders the fetched images directly in the browser.
  1. SearchImageService and Implementations:
  • An interface (SearchImageService.java) defining the contract for fetching image URLs.
  • Two implementations (DogImageService.java and FoxImageService.java) that provide image URLs from different sources.
  1. loadImageContent Method:
  • A custom method within the SearchImageServlet to fetch image content as bytes from the provided image URL.
  1. JSON Response Handling:
  • The servlet processes JSON responses from external services.
  • Handles cases where image URLs are provided either in a "message" or an "image" property within the JSON response.
  1. Error Handling:
  • Includes error handling to manage cases where the requested image is not found or when errors occur during image retrieval.
  • This PR enables users to select an image type, fetch image URLs from external services, and display the images directly within an AEM application.

@abhishekanandttn
Copy link
Owner Author

Below are the results after successful implementation.

when we hit the servlet with defined parameters.

DOG http://localhost:5502/bin/searchimage?type=dog
Screenshot 2023-09-24 163634

FOX http://localhost:5502/bin/searchimage?type=fox
Screenshot 2023-09-24 163651

@abhishekanandttn abhishekanandttn merged commit ee795b3 into develop Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant